enum dir {VER,HOR,N};

void init();
void deinit();

class Rectangle
{
  protected:
    float w[2][2];
    int color[3];
    BITMAP* bufor;
  public:
    Rectangle(BITMAP* bufor,float x1,float y1,float x2,float y2,int c1,int c2,int c3);
    void draw() { rect(this->bufor,this->w[0][0],this->w[0][1],this->w[1][0],this->w[1][1],makecol(this->color[0],this->color[1],this->color[2]));};
    void drawfill() { rectfill(this->bufor,this->w[0][0],this->w[0][1],this->w[1][0],this->w[1][1],makecol(this->color[0],this->color[1],this->color[2]));};
    float show(int a,int b) {return this->w[a][b];};
};

class Moving : public Rectangle
{
  protected:
    float speed[2];
  public:
    Moving(BITMAP* bufor,float x1,float y1,float x2,float y2,int c1,int c2,int c3,float speedx,float speedy) : Rectangle(bufor,x1,y1,x2,y2,c1,c2,c3) {this->speed[0]=speedx;this->speed[1]=speedy;};
    enum dir collision_in(Rectangle* object);
    enum dir collision_out(Rectangle* object);
    void move() {this->w[0][0]+=this->speed[0];this->w[0][1]+=this->speed[1];this->w[1][0]+=this->speed[0];this->w[1][1]+=this->speed[1];};
    float show_speed(int a) {return this->speed[a];};
};

class Dynamic : public Moving
{
  public:
    Dynamic(BITMAP* bufor,float x1,float y1,float x2,float y2,int c1,int c2,int c3,float speedx,float speedy) : Moving(bufor,x1,y1,x2,y2,c1,c2,c3,speedx,speedy){};
    void change_speed(float speedx,float speedy){this->speed[0]+=speedx;this->speed[1]+=speedy;};
};

class Physic : public Moving
{
  public:
    Physic(BITMAP* bufor,float x1,float y1,float x2,float y2,int c1,int c2,int c3,float speedx,float speedy) : Moving(bufor,x1,y1,x2,y2,c1,c2,c3,speedx,speedy){};
    void change_speed(float modx, float mody) {this->speed[1]*=mody; this->speed[0]*=modx;};
};

void col_pr(Physic* object, Rectangle* colliding);
void col_pd(Physic* object, Dynamic* colliding);
void col_dr(Dynamic* object, Rectangle* colliding);
